#include <gtk/gtk.h>

int main(int argc, char *argv[]) {
    // 初始化 GTK 库
    gtk_init(&argc, &argv);

    // 创建 GtkBuilder 对象
    GtkBuilder *builder = gtk_builder_new();
     // 创建 GtkNotebook
    GtkWidget *notebook = gtk_notebook_new();


    // 读取 Glade XML 文件
    gtk_builder_add_from_file(builder, "tg01.xml", NULL);

    // 获取窗口对象
    GtkWidget *window = GTK_WIDGET(gtk_builder_get_object(builder, "app"));

      // 设置窗口的默认大小
    gtk_window_set_default_size(GTK_WINDOW(window), 500, 480);
     // 隐藏标题栏
    gtk_window_set_decorated(GTK_WINDOW(window), FALSE);

    // 创建标签页的 GtkLabel 对象
    GtkWidget *label_page1 = gtk_label_new("page1");
    GtkWidget *label_page2 = gtk_label_new("page2");
    GtkWidget *label_page3 = gtk_label_new("page3");
    GtkWidget *label_page4 = gtk_label_new("page4");
    GtkWidget *label_page5 = gtk_label_new("page5");
    GtkWidget *label_page6 = gtk_label_new("page6");
    // 在 GtkNotebook 中添加页面
    gtk_notebook_append_page(GTK_NOTEBOOK(notebook), label_page1, NULL);
    gtk_notebook_set_tab_label(GTK_NOTEBOOK(notebook), label_page1, gtk_label_new("page1"));
    gtk_notebook_append_page(GTK_NOTEBOOK(notebook), label_page2, NULL);
    gtk_notebook_set_tab_label(GTK_NOTEBOOK(notebook), label_page2, gtk_label_new("page2"));
    gtk_notebook_append_page(GTK_NOTEBOOK(notebook), label_page3, NULL);
    gtk_notebook_set_tab_label(GTK_NOTEBOOK(notebook), label_page3, gtk_label_new("page3"));

    gtk_notebook_append_page(GTK_NOTEBOOK(notebook), label_page4, NULL);
    gtk_notebook_set_tab_label(GTK_NOTEBOOK(notebook), label_page4, gtk_label_new("page4"));
    gtk_notebook_append_page(GTK_NOTEBOOK(notebook), label_page5, NULL);
    gtk_notebook_set_tab_label(GTK_NOTEBOOK(notebook), label_page5, gtk_label_new("page5"));
    gtk_notebook_append_page(GTK_NOTEBOOK(notebook), label_page6, NULL);
    gtk_notebook_set_tab_label(GTK_NOTEBOOK(notebook), label_page6, gtk_label_new("page6"));
    // 将 notebook 添加到窗口中
    gtk_container_add(GTK_CONTAINER(window), notebook);
    // 连接窗口关闭信号
    g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL);

    // 显示窗口和其中的子部件
    gtk_widget_show_all(window);

    // 运行 GTK 主循环
    gtk_main();

    // 释放资源
    g_object_unref(builder);

    return 0;
}
